﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/TGVRManagerPage.Master" AutoEventWireup="true"
    CodeBehind="Account_List.aspx.cs" Inherits="TGVR.Manager.Pages.Account.Account_List" %>

<asp:Content ID="Content2" ContentPlaceHolderID="BCNBContent" runat="server">
    <style>
        .glyphicon-fixed
        {
            display: block !important;
            top: 0px;
        }
        
        a:hover
        {
            text-decoration: none;
        }
    </style>
    <!-- Search Form -->
    <div class="row smart-form">
        <section class="col col-4">
            <label class="input">
                <asp:TextBox CssClass="txtSearch" ID="txtSearch" runat="server" placeholder="Tìm kiếm"></asp:TextBox>
            </label>
        </section>
        <section class="col col-2">
            <label class="input">
                <asp:DropDownList ID="ddlUserGroup" DataTextField="GroupName" DataValueField="ID" 
                CssClass="form-control" runat="server">
                </asp:DropDownList>
            </label>
        </section>
        <section class="col col-6">
            <asp:Button ID="btnSearch" Text="Tìm kiếm" runat="server" Style="padding: 6px" CssClass="btn btn-primary" OnClick="btnSearch_Click" />
            <button type="button" style="padding: 6px" class="btn btn-default" onclick="window.history.back();">
                Trở về
            </button>
        </section>
    </div>
    <!-- // Search Form -->
    <!-- List data -->
    <div class="row">
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-0" data-widget-editbutton="false">
            <!-- widget options:
								usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

								data-widget-colorbutton="false
								data-widget-editbutton="false"
								data-widget-togglebutton="false"
								data-widget-deletebutton="false"
								data-widget-fullscreenbutton="false"
								data-widget-custombutton="false"
								data-widget-collapsed="true"
								data-widget-sortable="false"

								-->
            <header>
            <span class="widget-icon"><i class="fa fa-table"></i></span>
            <h2>Danh sách thành viên</h2>

            </header>
            <!-- widget div-->
            <div>
                <!-- widget edit box -->
                <div class="jarviswidget-editbox">
                    <!-- This area used as dropdown edit box -->
                </div>
                <!-- end widget edit box -->
                <!-- widget content -->
                <div class="widget-body">
                    <telerik:RadGrid Skin="" runat="server" ID="grvData" CssClass="table-responsive"
                        AllowCustomPaging="true" AllowPaging="true" PageSize="10" OnNeedDataSource="grvData_NeedDataSource"
                        AutoGenerateColumns="false" OnItemCommand="grvData_ItemCommand">
                        <PagerStyle Mode="NumericPages" AlwaysVisible="true" ShowPagerText="false" CssClass="pagination pagination-sm" />
                        <MasterTableView CssClass="table table-bordered" SkinID="">
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Mã số">
                                    <ItemTemplate>
                                        <a href="/Pages/Account/Account_Detail.aspx?AccountID=<%#Eval("UserId")%>" rel="nofollow"
                                            target="_blank">
                                            <%#Eval("UserId")%></a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Hình ảnh">
                                    <ItemTemplate>
                                        <a href="/Pages/Account/Account_Detail.aspx?AccountID=<%#Eval("UserId")%>" rel="nofollow"
                                            target="_blank">
                                            <img style='width: 50px; height: 50px;' src="http://thegioivere.net/<%#Eval("Avatar")%>"
                                                alt="image" /></a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="Name" HeaderText="Họ và tên">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Username" HeaderText="Username">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Phone" HeaderText="Điện thoại">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="GroupName" HeaderText="Nhóm">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ManagerName" HeaderText="Quản lý bởi">
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn HeaderText="Ngày tạo">
                                    <ItemTemplate>
                                        <%#Convert.ToDateTime( Eval("CreatedDate")).ToString("ddMMMyy").ToUpper()%>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Trạng thái" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:LinkButton CommandName="Active" CommandArgument='<%#Eval("UserId") %>' ID="Label1"
                                            CssClass="label label-danger" Text="Make Active" runat="server" Visible='<%# !Convert.ToBoolean( Eval("IsConfirmed")) %>'></asp:LinkButton>
                                        <asp:LinkButton CommandName="DeActive" CommandArgument='<%#Eval("UserId") %>' CssClass="label label-primary"
                                            Text="Make UnActive" runat="server" Visible='<%# Convert.ToBoolean( Eval("IsConfirmed")) %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn ItemStyle-CssClass="glyphicon glyphicon-fixed">
                                    <ItemTemplate>
                                        <a href="#" class="glyphicon-remove" onclick='ConfirmOnRow("<%=grvData.ClientID %>","DeleteRow","<%#Eval("UserId") %>","Xác nhận xóa dữ liệu?");'>
                                        </a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>
                <!-- end widget content -->
            </div>
            <!-- end widget div -->
        </div>
        <!-- end widget -->
    </div>
    <!-- //List data -->
    <!-- Ajax request -->
    <telerik:RadAjaxManager ID="RadAjaxManage1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="grvData" LoadingPanelID="LoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="grvData">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="grvData" LoadingPanelID="LoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Skin="Vista" IsSticky="true"
        EnableEmbeddedSkins="false" Style="position: fixed; top: 0; left: 0; height: 100%;
        width: 100%; background: rgba( 156, 156, 156, .5 ); z-index: 100000; cursor: wait">
        <asp:Image ID="Image1" runat="server" ImageAlign="Middle" ImageUrl="/App_Themes/SmartAdmin/img/loading.gif"
            Style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto">
        </asp:Image>
    </telerik:RadAjaxLoadingPanel>
    <!-- Ajax request -->
    <telerik:RadCodeBlock runat="server" ID="script_InputType_List">
        <script type="text/javascript">
            function CloseWindow() {
                $('.close').click();
            }

            function OpenWindow() {
                $('#ModalManualOpen').click();
            }

            function ConfirmOnRow(tableClientID, argName, argValue, text) {
                $.confirm({
                    text: text,
                    title: "",
                    confirmButton: "Đồng ý",
                    cancelButton: "Huỷ",
                    confirm: function (button) {
                        var masterTable = $find(tableClientID).get_masterTableView();
                        //alert(masterTable.get_pageCount());
                        masterTable.fireCommand(argName, argValue);
                    },
                    cancel: function (button) {

                    }
                });
            }

        </script>
    </telerik:RadCodeBlock>
</asp:Content>
